#include "llSyntax.hpp"
#include "llCommandList.hpp"
using namespace llmake;

#include <iostream>
using namespace std;
#include <boost/algorithm/string.hpp>


void llSyntaxEngine::getCommand( llCommandList &commands)
{
	for (llLexList::iterator iter = m_Lexs.begin();iter != m_Lexs.end(); ++iter)
	{
		llTokenList::iterator iterToken = iter->m_Tokens.begin();
		CommandInstanceCreatorMap::iterator creator;
		string key(iterToken->m_Token);
		string key_ori = key;
		boost::to_lower(key);
		creator = gCommandInstanceCreator.find(key);
		if ( creator != gCommandInstanceCreator.end())
		{
			shared_ptr<llCommandBase> p ;
			creator->second(iter->m_Tokens,m_Owner,p);
			commands.push_back( p );
		}
		else
		{
//			cout<<"<"<<iterToken->m_Token<<"> self defined command"<<endl;
			shared_ptr<llCommandBase> p ;
			llPreProcess__selfDefine::createCommandInstance( key_ori,iter->m_Tokens,m_Owner,p);
			commands.push_back( p );
		}
	}
}
